﻿var runer = {
    runer: false,
    btnUp: false,
    btnDown: false,
    lis: false,
    pageIndex: 1,
    pageSize: 10,
    pageCount: 0,
    pageHeight: 450,
    init: function() {
        this.runer = $('#runer');
        this.btnUp = $('#up');
        this.btnDown = $('#down');
        this.lis = $('#runer li');
        this.pageCount = Math.ceil(this.lis.length / this.pageSize);
        this.btnUp.click(this.up);
        this.btnDown.click(this.down);
    },
    up: function() {
        if (runer.pageIndex > 1) {
            runer.runer.animate({ marginTop: -runer.pageHeight * (runer.pageIndex - 2) });
            runer.pageIndex--;
        }
    },
    down: function() {
        if (runer.pageIndex < runer.pageCount) {
            runer.runer.animate({ marginTop: -runer.pageHeight * runer.pageIndex });
            runer.pageIndex++;
        }
    }
}

$(document).ready(function() {
    runer.init();
});